#include "mechanicalswitchspectrum.h"
#include "private/mechanicalspectrumprivatedefine.h"
#include "common/dataspecificationutils.h"
#include "common/binaryprocesshelper.h"
#include "common/xmldocument.h"
#include "private/spectrumdatafilecommondefine.h"
#include "common/xmlprocesshelper.h"
#include <QDebug>

namespace DataSpecificationGW
{
    class MechanicalSwitchSpectrumPrivate
    {
    public:
        MechanicalSwitchExtInformationPrivate m_stMechanicalSwitchExtInformationPrivate;
    };

    MechanicalSwitchSpectrum::MechanicalSwitchSpectrum()
        : MechanicalSpectrum(),
          m_pMechanicalSwitchSpectrumPrivate(new MechanicalSwitchSpectrumPrivate)
    {
        setSpectrumTypeCode(SPECTRUM_CODE_MECH_SWITCH);
    }

    MechanicalSwitchSpectrum::~MechanicalSwitchSpectrum()
    {
    }

    /************************************************
     * 函数名   : spectrumName
     * 输入参数 : NULL
     * 输出参数 : NULL
     * 返回值   : QString
     * 功能     : 图谱名称
     ************************************************/
    QString MechanicalSwitchSpectrum::spectrumName() const
    {
        return STR_FILE_NODE_MECHANICAL_SWITCH;
    }

    /************************************************
     * 函数名   : setMechanicalSwitchExtInformation
     * 输入参数 :
       const MechanicalSwitchExtInformation& stMechanicalSwitchExtInformation: MechanicalSwitchExtInformation
     * 输出参数 : NULL
     * 返回值   : void
     * 功能     : 设置MechanicalSwitchExtInformation
     ************************************************/
    void MechanicalSwitchSpectrum::setMechanicalSwitchExtInformation(const MechanicalSwitchExtInformation& stMechanicalSwitchExtInformation)
    {
        m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucMechDataType = stMechanicalSwitchExtInformation.eMechDataType;
        m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucOperatingMechanismType = stMechanicalSwitchExtInformation.eOperatingMechanismType;
        m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucMechStoredEnergyType = stMechanicalSwitchExtInformation.eMechStoredEnergyType;
        m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchOpenTime = stMechanicalSwitchExtInformation.fSwitchOpenTime;
        m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchCloseTime = stMechanicalSwitchExtInformation.fSwitchCloseTime;
        m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchTwiceTime = stMechanicalSwitchExtInformation.fSwitchTwiceTime;
        m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchOpenSync = stMechanicalSwitchExtInformation.fSwitchOpenSync;
        m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchCloseSync = stMechanicalSwitchExtInformation.fSwitchCloseSync;
        m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchTwiceSync = stMechanicalSwitchExtInformation.fSwitchTwiceSync;
        m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchShotTime = stMechanicalSwitchExtInformation.fSwitchShotTime;
        m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchNoCurrentTime = stMechanicalSwitchExtInformation.fSwitchNoCurrentTime;
        m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fConversionFactor = stMechanicalSwitchExtInformation.fConversionFactor;
    }

    /************************************************
     * 函数名   : getMechanicalSwitchExtInformation
     * 输入参数 : NULL
     * 输出参数 :
       MechanicalSwitchExtInformation& stMechanicalSwitchExtInformation: MechanicalSwitchExtInformation
     * 返回值   : void
     * 功能     : 获取MechanicalSwitchExtInformation
     ************************************************/
    void MechanicalSwitchSpectrum::getMechanicalSwitchExtInformation(MechanicalSwitchExtInformation& stMechanicalSwitchExtInformation)
    {
        stMechanicalSwitchExtInformation.eMechDataType = static_cast<MechDataType>(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucMechDataType);
        stMechanicalSwitchExtInformation.eOperatingMechanismType = static_cast<OperatingMechanismType>(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucOperatingMechanismType);
        stMechanicalSwitchExtInformation.eMechStoredEnergyType = static_cast<MechStoredEnergyType>(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucMechStoredEnergyType);
        stMechanicalSwitchExtInformation.fSwitchOpenTime = m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchOpenTime;
        stMechanicalSwitchExtInformation.fSwitchCloseTime = m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchCloseTime;
        stMechanicalSwitchExtInformation.fSwitchTwiceTime = m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchTwiceTime;
        stMechanicalSwitchExtInformation.fSwitchOpenSync = m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchOpenSync;
        stMechanicalSwitchExtInformation.fSwitchCloseSync = m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchCloseSync;
        stMechanicalSwitchExtInformation.fSwitchTwiceSync = m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchTwiceSync;
        stMechanicalSwitchExtInformation.fSwitchShotTime = m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchShotTime;
        stMechanicalSwitchExtInformation.fSwitchNoCurrentTime = m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchNoCurrentTime;
        stMechanicalSwitchExtInformation.fConversionFactor = m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fConversionFactor;
    }

    /************************************************
     * 函数名   : saveBinarySpectrumExtInfo
     * 输入参数 :
       QDataStream& out: 输出流
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 保存二进制可扩展信息段
     ************************************************/
    bool MechanicalSwitchSpectrum::saveBinarySpectrumExtInfo(QDataStream& out)
    {
        MechanicalSpectrum::saveBinarySpectrumExtInfo(out);

        out.device()->seek(MECH_COMMON_LENGTH);

        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipMechDataType) out << m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucMechDataType;
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipOperatingMechanismType) out << m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucOperatingMechanismType;
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipMechStoredEnergyType) out << m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucMechStoredEnergyType;
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchOpenTime) out << m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchOpenTime;
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchCloseTime) out << m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchCloseTime;
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchTwiceTime) out << m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchTwiceTime;
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchOpenSync) out << m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchOpenSync;
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchCloseSync) out << m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchCloseSync;
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchTwiceSync) out << m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchTwiceSync;
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchShotTime) out << m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchShotTime;
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchNoCurrentTime) out << m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchNoCurrentTime;
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipConversionFactor) out << m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fConversionFactor;

        return true;
    }

    /************************************************
     * 函数名   : saveXMLSpectrumExtInfo
     * 输入参数 :
       XMLDocument& xmlDocumentObj: xml文档对象
       QDomElement& element: dom元素
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 保存XML可扩展信息段
     ************************************************/
    bool MechanicalSwitchSpectrum::saveXMLSpectrumExtInfo(XMLDocument& xmlDocumentObj, QDomElement& element)
    {
        MechanicalSpectrum::saveXMLSpectrumExtInfo(xmlDocumentObj, element);

        xmlDocumentObj.beginElement(element);
        xmlDocumentObj.beginElement(STR_SPECTRUM_NODE_EXTINFORMATION);

        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipMechDataType) xmlDocumentObj.setValue(TEXT_MECH_DATA_TYPE, QString::number(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucMechDataType));
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipOperatingMechanismType) xmlDocumentObj.setValue(TEXT_MECH_FUNCTION_TYPE, QString::number(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucOperatingMechanismType));
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipMechStoredEnergyType) xmlDocumentObj.setValue(TEXT_MECH_STORAGE_TYPE, QString::number(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucMechStoredEnergyType));
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchOpenTime) xmlDocumentObj.setValue(TEXT_SWITCH_OPEN_TIME, QString::number(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchOpenTime, 'f', 1));
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchCloseTime) xmlDocumentObj.setValue(TEXT_SWITCH_CLOSE_TIME, QString::number(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchCloseTime, 'f', 1));
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchTwiceTime) xmlDocumentObj.setValue(TEXT_SWITCH_TWICE_TIME, QString::number(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchTwiceTime, 'f', 1));
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchOpenSync) xmlDocumentObj.setValue(TEXT_SWITCH_OPEN_SYNC, QString::number(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchOpenSync, 'f', 1));
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchCloseSync) xmlDocumentObj.setValue(TEXT_SWITCH_CLOSE_SYNC, QString::number(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchCloseSync, 'f', 1));
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchTwiceSync) xmlDocumentObj.setValue(TEXT_SWITCH_TWICE_SYNC, QString::number(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchTwiceSync, 'f', 1));
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchShotTime) xmlDocumentObj.setValue(TEXT_SWITCH_SHOT_TIME, QString::number(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchShotTime, 'f', 1));
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchNoCurrentTime) xmlDocumentObj.setValue(TEXT_SWITCH_NO_CURRENT_TIME, QString::number(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchNoCurrentTime, 'f', 1));
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipConversionFactor) xmlDocumentObj.setValue(TEXT_CONVERSION_FACTOR, QString::number(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fConversionFactor, 'f', 4));

        return true;
    }

    /************************************************
     * 函数名   : saveJSONSpectrumExtInfo
     * 输入参数 :
       rapidjson::Document::AllocatorType& alloc:
       rapidjson::Value& jsonValue: json数据
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 保存JSON可扩展信息段
     ************************************************/
    bool MechanicalSwitchSpectrum::saveJSONSpectrumExtInfo(rapidjson::Document::AllocatorType& alloc, rapidjson::Value& jsonValue)
    {
        MechanicalSpectrum::saveJSONSpectrumExtInfo(alloc, jsonValue);

        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipMechDataType) saveJSONField(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucMechDataType, TEXT_MECH_DATA_TYPE, alloc, jsonValue);
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipOperatingMechanismType) saveJSONField(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucOperatingMechanismType, TEXT_MECH_FUNCTION_TYPE, alloc, jsonValue);
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipMechStoredEnergyType) saveJSONField(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucMechStoredEnergyType, TEXT_MECH_STORAGE_TYPE, alloc, jsonValue);
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchOpenTime) saveJSONField(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchOpenTime, TEXT_SWITCH_OPEN_TIME, alloc, jsonValue);
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchCloseTime) saveJSONField(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchCloseTime, TEXT_SWITCH_CLOSE_TIME, alloc, jsonValue);
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchTwiceTime) saveJSONField(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchTwiceTime, TEXT_SWITCH_TWICE_TIME, alloc, jsonValue);
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchOpenSync) saveJSONField(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchOpenSync, TEXT_SWITCH_OPEN_SYNC, alloc, jsonValue);
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchCloseSync) saveJSONField(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchCloseSync, TEXT_SWITCH_CLOSE_SYNC, alloc, jsonValue);
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchTwiceSync) saveJSONField(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchTwiceSync, TEXT_SWITCH_TWICE_SYNC, alloc, jsonValue);
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchShotTime) saveJSONField(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchShotTime, TEXT_SWITCH_SHOT_TIME, alloc, jsonValue);
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchNoCurrentTime) saveJSONField(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchNoCurrentTime, TEXT_SWITCH_NO_CURRENT_TIME, alloc, jsonValue);
        if (!m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipConversionFactor) saveJSONField(m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fConversionFactor, TEXT_CONVERSION_FACTOR, alloc, jsonValue);

        return true;
    }

    /************************************************
     * 函数名   : parseBinarySpectrumExtInfo
     * 输入参数 :
       QDataStream& in: 输入流
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 解析二进制可扩展信息段
     ************************************************/
    bool MechanicalSwitchSpectrum::parseBinarySpectrumExtInfo(QDataStream& in)
    {
        MechanicalSpectrum::parseBinarySpectrumExtInfo(in);

        if (!in.device()->seek(MECH_COMMON_LENGTH))
        {
            qDebug() << "MechanicalSwitchSpectrum::parseBinarySpectrumExtInfo failed";
            return false;
        }

        parseBinaryField(in, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipMechDataType, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucMechDataType, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasmechDataType);
        parseBinaryField(in, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipOperatingMechanismType, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucOperatingMechanismType, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasOperatingMechanismType);
        parseBinaryField(in, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipMechStoredEnergyType, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucMechStoredEnergyType, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasMechStoredEnergyType);
        parseBinaryField(in, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchOpenTime, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchOpenTime, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchOpenTime);
        parseBinaryField(in, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchCloseTime, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchCloseTime, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchCloseTime);
        parseBinaryField(in, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchTwiceTime, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchTwiceTime, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchTwiceTime);
        parseBinaryField(in, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchOpenSync, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchOpenSync, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchOpenSync);
        parseBinaryField(in, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchCloseSync, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchCloseSync, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchCloseSync);
        parseBinaryField(in, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchTwiceSync, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchTwiceSync, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchTwiceSync);
        parseBinaryField(in, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchShotTime, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchShotTime, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchShotTime);
        parseBinaryField(in, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipswitchNoCurrentTime, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchNoCurrentTime, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchNoCurrentTime);
        parseBinaryField(in, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bSkipConversionFactor, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fConversionFactor, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasConversionFactor);

        return in.status() == QDataStream::Ok;
    }

    /************************************************
     * 函数名   : parseXMLSpectrumExtInfo
     * 输入参数 :
       XMLDocument& xmlDocumentObj: xml文档对象
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 解析XML可扩展信息段
     ************************************************/
    bool MechanicalSwitchSpectrum::parseXMLSpectrumExtInfo(XMLDocument& xmlDocumentObj)
    {
        MechanicalSpectrum::parseXMLSpectrumExtInfo(xmlDocumentObj);

        xmlDocumentObj.beginElement(spectrumName());
        xmlDocumentObj.beginElement(STR_SPECTRUM_NODE_EXTINFORMATION);       

        parseXMLField(xmlDocumentObj, TEXT_MECH_DATA_TYPE, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucMechDataType, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasmechDataType);
        parseXMLField(xmlDocumentObj, TEXT_MECH_FUNCTION_TYPE, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucOperatingMechanismType, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasOperatingMechanismType);
        parseXMLField(xmlDocumentObj, TEXT_MECH_STORAGE_TYPE, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucMechStoredEnergyType, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasMechStoredEnergyType);
        parseXMLField(xmlDocumentObj, TEXT_SWITCH_OPEN_TIME, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchOpenTime, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchOpenTime);
        parseXMLField(xmlDocumentObj, TEXT_SWITCH_CLOSE_TIME, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchCloseTime, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchCloseTime);
        parseXMLField(xmlDocumentObj, TEXT_SWITCH_TWICE_TIME, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchTwiceTime, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchTwiceTime);
        parseXMLField(xmlDocumentObj, TEXT_SWITCH_OPEN_SYNC, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchOpenSync, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchOpenSync);
        parseXMLField(xmlDocumentObj, TEXT_SWITCH_CLOSE_SYNC, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchCloseSync, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchCloseSync);
        parseXMLField(xmlDocumentObj, TEXT_SWITCH_TWICE_SYNC, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchTwiceSync, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchTwiceSync);
        parseXMLField(xmlDocumentObj, TEXT_SWITCH_SHOT_TIME, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchShotTime, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchShotTime);
        parseXMLField(xmlDocumentObj, TEXT_SWITCH_NO_CURRENT_TIME, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchNoCurrentTime, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchNoCurrentTime);
        parseXMLField(xmlDocumentObj, TEXT_CONVERSION_FACTOR, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fConversionFactor, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasConversionFactor);

        xmlDocumentObj.endElement();
        xmlDocumentObj.endElement();

        return true;
    }

    /************************************************
     * 函数名   : parseJSONSpectrumExtInfo
     * 输入参数 :
       const rapidjson::Value& jsonValue: json数据
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 解析JSON可扩展信息段
     ************************************************/
    bool MechanicalSwitchSpectrum::parseJSONSpectrumExtInfo(const rapidjson::Value& jsonValue)
    {
        MechanicalSpectrum::parseJSONSpectrumExtInfo(jsonValue);

        parseJSONField(jsonValue, TEXT_MECH_DATA_TYPE, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucMechDataType, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasmechDataType);
        parseJSONField(jsonValue, TEXT_MECH_FUNCTION_TYPE, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucOperatingMechanismType, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasOperatingMechanismType);
        parseJSONField(jsonValue, TEXT_MECH_STORAGE_TYPE, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.ucMechStoredEnergyType, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasMechStoredEnergyType);
        parseJSONField(jsonValue, TEXT_SWITCH_OPEN_TIME, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchOpenTime, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchOpenTime);
        parseJSONField(jsonValue, TEXT_SWITCH_CLOSE_TIME, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchCloseTime, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchCloseTime);
        parseJSONField(jsonValue, TEXT_SWITCH_TWICE_TIME, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchTwiceTime, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchTwiceTime);
        parseJSONField(jsonValue, TEXT_SWITCH_OPEN_SYNC, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchOpenSync, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchOpenSync);
        parseJSONField(jsonValue, TEXT_SWITCH_CLOSE_SYNC, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchCloseSync, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchCloseSync);
        parseJSONField(jsonValue, TEXT_SWITCH_TWICE_SYNC, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchTwiceSync, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchTwiceSync);
        parseJSONField(jsonValue, TEXT_SWITCH_SHOT_TIME, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchShotTime, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchShotTime);
        parseJSONField(jsonValue, TEXT_SWITCH_NO_CURRENT_TIME, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fSwitchNoCurrentTime, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasswitchNoCurrentTime);
        parseJSONField(jsonValue, TEXT_CONVERSION_FACTOR, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.fConversionFactor, m_pMechanicalSwitchSpectrumPrivate->m_stMechanicalSwitchExtInformationPrivate.bHasConversionFactor);

        return true;
    }

}
